package cn.golxen.blog.exception;

import cn.golxen.blog.commons.utils.Result;
import cn.golxen.blog.exception.exceptionClass.*;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionController {

    @ExceptionHandler(value = {AddEssayException.class})
    public Result addEssayException(AddEssayException e){
        return new Result(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(value = {ThreadPoolException.class})
    public Result threadPoolException(ThreadPoolException e){
        return new Result(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(value = {DeleteEssayException.class})
    public Result deleteEssayException(DeleteEssayException e){
        return new Result(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(value = {UpdateEssayException.class})
    public Result updateEssayException(UpdateEssayException e){
        return new Result(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(value = {AddCategoryException.class})
    public Result addCategoryException(AddCategoryException e){return new Result(e.getCode(),e.getMessage());}

    @ExceptionHandler(value = {DeleteCategoryException.class})
    public Result deleteCategoryException(DeleteCategoryException e){
        return new Result(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(value = {AddLabelException.class})
    public Result addLabelException(AddLabelException e){ return new Result(e.getCode(),e.getMessage());}

    @ExceptionHandler(value = {DeleteLabelException.class})
    public Result deleteLabelException(DeleteLabelException e){ return new Result(e.getCode(),e.getMessage());}

    @ExceptionHandler(value = {GetLabelByCategoryEmptyException.class})
    public Result getLabelByCategoryEmptyException(GetLabelByCategoryEmptyException e){
        return new Result(e.getCode(), e.getMessage());
    }
    @ExceptionHandler(value = {GetEssayEmptyException.class})
    public Result getEssayByCategoryEmptyException(GetEssayEmptyException e){
        return new Result(e.getCode(), e.getMessage());
    }
    @ExceptionHandler(value = {AddDraftException.class})
    public Result addDraftException(AddDraftException e){
        return new Result(e.getCode(), e.getMessage());
    }
    @ExceptionHandler(value = {DeleteDraftException.class})
    public Result deleteDraftException(DeleteDraftException e){
        return new Result(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(value = {UpdateAdminException.class})
    public Result updateAdminException(UpdateAdminException e){
        return new Result(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(value = {GetTokenException.class})
    public Result getTokenException(GetTokenException e){
        return new Result(e.getCode(), e.getMessage());
    }
}
